import Vue from 'vue'
import App from './App'
// 引入全局uView
import uView from '@/uni_modules/uview-ui'
Vue.use(uView);

Vue.config.productionTip = false

App.mpType = 'app'

Vue.mixin({
	methods: {
		// 给vue的data赋值
		setData: function(obj, callback) {
			let that = this;
			let keys = [];
			let val, data;
			Object.keys(obj).forEach(function(key) {
				keys = key.split('.');
				val = obj[key];
				data = that.$data;
				keys.forEach(function(key2, index) {
					if (index + 1 == keys.length) {
						that.$set(data, key2, val);
					} else {
						if (!data[key2]) {
							that.$set(data, key2, {});
						}
					}
					data = data[key2];
				})
			});
			callback && callback();
		} 
	}
});

//引入vuex
import store from './store'
Vue.prototype.$store = store

// 引入工具函数
import tools from "./common/tools";
Vue.prototype.$app = tools;
Vue.prototype.$noMultipleClicks = tools.noMultipleClicks;
// 发送请求
import $api from './common/api.js';
Vue.prototype.$api = $api;
// import share from "./common/share";
// Vue.mixin(share)
Vue.config.productionTip = false;
Vue.prototype.$onLaunched = new Promise(resolve => {
    Vue.prototype.$isResolve = resolve
})
App.mpType = "app";
const app = new Vue({
    store, //挂载
    ...App,
});
app.$mount();
